<?php
/**
 * Enter description here...
 *	
 * STATUS_DISABLE 0 
 * STATUS_ABLE 1 
 */
class Members extends CActiveRecord {
	public static function model($className = __CLASS__) {
		return parent::model ( $className );
	}
	
	public function tableName() {
		return '{{member}}';
	}
	
	public function rules() {
		return array (
			
			array (
				
				'passport,password,uuid,regtime', 
				'required', 
				'message' => '不能为空' 
			), 
			array (
				
				'email,groupid,regip,level,scores,state,mailstate,suffix,nickname', 
				'safe' 
			) 
		);
	}
	
	public function relations() {
		return array (
			
			'meminfo' => array (
				
				self::HAS_ONE, 
				'meminfo', 
				'uuid' 
			) 
		);
	}
	
	public function attributeLabels() {
		return array (
			
			'id' => 'id', 
			'passport' => 'passport', 
			'password' => 'password', 
			'uuid' => 'uuid', 
			'regtime' => 'regtime', 
			'state' => 'state', 
			'email' => 'email', 
			'groupid' => 'groupid', 
			'regip' => 'regip', 
			'level' => 'level', 
			'mailstate' => 'mailstate', 
			'scores' => 'scores', 
			'suffix' => 'suffix', 
			'nickname' => 'nickname' 
		);
	}
	public function getMembers() {
		$rows = $this->with ( 'meminfo' )->findAll ( array (
			
			"condition" => "state>0" 
		) );
		$ret = CommonFunc::YiiObjectToArray ( $rows, "all" ,'meminfo');
		return $ret;
	}
	public function getMembersById($id){
		$rows = $this->findByPk($id);
		$ret = CommonFunc::YiiObjectToArray ( $rows, "one");
		return $ret;
	}
}
?>
